package cn.itrigger.dynamic.sql.condition;

import cn.itrigger.dynamic.sql.render.TableAliasCalculator;
import cn.itrigger.dynamic.sql.structure.BasicColumn;

/**
 * @author admin
 * @date 2018/9/26
 **/
public abstract class AbstractColumnComparisonCondition<T> implements VisitableCondition<T> {

    protected BasicColumn column;

    protected AbstractColumnComparisonCondition(BasicColumn column) {
        this.column = column;
    }

    @Override
    public <R> R accept(ConditionVisitor<T, R> visitor) {
        return visitor.visit(this);
    }

    public String renderCondition(String columnName, TableAliasCalculator tableAliasCalculator) {
        return renderCondition(columnName, column.renderWithTableAlias(tableAliasCalculator));
    }

    protected abstract String renderCondition(String leftColumn, String rightColumn);
}
